from selenium import webdriver
from selenium.webdriver.common.by import By

def setup():
    option = get_default_chrome_options()
    driver = webdriver.Chrome(service=webdriver.ChromeService(service_args=['--log-level=DEBUG'],log_output=r'.\log\selenium.log'),options=option)
    driver.get('https://www.selenium.dev/selenium/web/inputs.html')
    return driver


def test_eight_components():
    driver = setup()

    # Click on the checkbox
    # Handle the email input field
    email_input = driver.find_element(By.NAME, "email_input")
    email_input.clear()  # Clear field

    email = "admin@localhost.dev"
    email_input.send_keys(email)  # Enter text

def main():
    test_eight_components()

def get_default_chrome_options():
    options = webdriver.ChromeOptions()
    options.add_argument("--no-sandbox")
    """保持浏览器的打开状态
        将 detach 参数设置为true将在驱动过程结束后保持浏览器的打开状态."""
    options.add_experimental_option('detach', True)
    return options

def teardown(driver):
    driver.quit()

if __name__ == '__main__':
    main()